/**
  *@File文件:UserFocusService.java
  *@Date日期:2017年7月14日 下午4:51:02
  *@Copyright版权:Corporation 2017
  */
package com.qiaomengapp.serviceImp;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.qiaomengapp.bean.ShopGoodWrap;
import com.qiaomengapp.bean.ShopWarp;
import com.qiaomengapp.dao.UserFocusMapper;
import com.qiaomengapp.exception.CustomException;
import com.qiaomengapp.service.IUserFocusService;

/**
 *@Description描述:
 *@Author作者 jinxin
 *@Date日期:2017年7月14日
 */
@Service
public class ImpUserFocusService implements IUserFocusService{
	@Autowired
	private UserFocusMapper userFocusMapper;
	
	//删除用户关注的商铺(同时商铺收藏数量要减1在shop那边写)
	public int delete_shop(int userId,int shopId) throws CustomException{
		int i = userFocusMapper.delete_shop(userId, shopId);
		if(i==0){
			throw new CustomException("删除用户关注的商铺失败");
		}
		return i;
		
	}
		
		//删除用户所关注的商品(同时商品关注量量减1在shopGood那边写)
	public int delete_shopGood(int userId,int shopGoodId) throws CustomException{
		int i = userFocusMapper.delete_shopGood(userId, shopGoodId);
		if(i==0){
			throw new CustomException("删除用户关注的商品失败");
		}
		return i;
		
	}
	
	//显示用户关注的商铺
	public	List<ShopWarp> select_shop(int userId){
		List<ShopWarp> list = userFocusMapper.select_shop(userId);
		return list;
	}
		
		//显示用户关注的商品
	public	List<ShopGoodWrap> select_shopGood(int userId){
		List<ShopGoodWrap> list = userFocusMapper.select_shopGood(userId);
		return list;
	}
	
	//用户添加收藏商品
	public int insert_shopGood(int userId,int shopGoodId) throws CustomException{
		int i = userFocusMapper.insert_shopGood(userId, shopGoodId);
		if(i==0){
			throw new CustomException("收藏商品失败");
		}
		return i;
	}
	
	//用户添加关注店铺
	public int insert_shop(int userId,int shopId) throws CustomException{
		int i = userFocusMapper.insert_shop(userId, shopId);
		if(i==0){
			throw new CustomException("关注店铺失败");
		}
		return i;
	}

}
